package Collection;

import java.util.*;

public class Exercise {
    public static void main(String[] args) {
        /*
        Collection c=new ArrayList();
        c.add(new Point(1,2));
        c.add(new Point(3,4));
        c.add(new Point(5,6));
        c.add(new Point(7,8));
        c.add(new Point(9,0));
        c.add(new Point(1,2));
        System.out.println(c);

        Point p=new Point(1,2);
        boolean contains= c.contains(p);
        System.out.println("是否包含："+contains);
        c.remove(p);
        System.out.println(c);

        Collection b=new ArrayList();
        Point b1=new Point(1,2);
        b.add(b1);
        System.out.println("b1:"+b1);
        System.out.println("b:"+b);

        b1.setY(99);
        System.out.println("b1:"+b1);
        System.out.println("b"+b);

        Collection o=new ArrayList();
        o.add("qwq");
        o.add("OvO");
        o.add("QUQ");
        o.add("TAT");
        o.add("=A=");
        System.out.println(o);
        System.out.println("size:"+o.size());
        System.out.println("是否为空集"+c.isEmpty());
        o.clear();
        System.out.println("集合已清空");
        System.out.println("o");
        System.out.println("size:"+c.size());
        System.out.println("是否为空集"+c.isEmpty());

        String[]array={"one","two","three","four","five"};
        System.out.println("array:"+ Arrays.toString(array));
        List<String> lis=Arrays.asList(array);
        System.out.println("lis"+lis);

        array[1]="ten";
        System.out.println("array:"+Arrays.toString(array));
        System.out.println("lis:"+lis);
        lis.set(4,"nine");
        System.out.println("array:"+Arrays.toString(array));
        System.out.println("lis:"+lis);
        lis.add("one");


        Collection q=new ArrayList();
        q.add("hi");
        q.add("hello");
        q.add("hellow");
        System.out.println("q:"+q);

        Collection q2=new ArrayList();
        q2.add("what");
        q2.add("who");
        q2.add("why");
        System.out.println("q2:"+q2);

        q.addAll(q2);
        System.out.println("q:"+q);
        System.out.println("q2:"+q2);

        Collection q3=new ArrayList();
        q3.add("what");
        q3.add("are");
        q3.add("you");
        System.out.println("q3:"+q3);
        boolean contains=q2.containsAll(q3);
        System.out.println("是否包含："+contains);
        q.retainAll(q3);
        System.out.println("q:"+q);
        System.out.println("q3:"+q3);

        q.removeAll(q3);
        System.out.println("q:"+q);
        System.out.println("q3:"+q3);



        Collection<String>c=new ArrayList<>();
        c.add("qwq");
        c.add("ovo");
        c.add("=v=");
        c.add("vov");
        c.add("mom");
        System.out.println(c);

        String[]array=c.toArray(new String[9]);
        System.out.println(Arrays.toString(array));



        Collection<Point>q=new ArrayList<>();
        q.add(new Point(1,2));
        q.add(new Point(2,3));
        q.add(new Point(3,4));
        q.add(new Point(4,5));

        Iterator<Point>it=q.iterator();
        while(it.hasNext()){
            Point w=it.next();
            System.out.println(w);
        }

        for(Point w:q){
            System.out.println(w);
        }



        Collection c=new ArrayList();
        c.add("qwq");
        c.add("***");
        c.add("=V=");
        c.add("***");
        c.add("wow");
        c.add("***");
        c.add("QVQ");
        System.out.println(c);

        Iterator it = c.iterator();
        while (it.hasNext()){
            String str=(String)it.next();
            System.out.println(str);
            if ("***".equals(str)){
                //c.remove(str);
                it.remove();
            }
        }
        System.out.println(c);



        String[] array = {"one","two","three","four","five"};
        for(int i=0;i<array.length;i++){
            System.out.println(array[i]);
        }
        for(String str : array){
            System.out.println(str);
        }

        Collection c = new ArrayList();
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        Iterator it = c.iterator();
        while(it.hasNext()){
            String str = (String)it.next();
            System.out.println(str);
        }
        for(Object obj : c){
            String str = (String)obj;
            System.out.println(str);
        }
*/
        Collection c=new ArrayList();
        c.add(new Point(1,2));
        c.add(new Point(3,4));
        c.add(new Point(5,6));
        c.add(new Point(7,8));
        c.add(new Point(9,0));
        c.add(new Point(1,2));
        System.out.println(c);

        Point p=new Point(1,2);
        boolean contains= c.contains(p);
        System.out.println("是否包含："+contains);
        c.remove(p);
        System.out.println(c);

        Collection b=new ArrayList();
        Point b1=new Point(1,2);
        b.add(b1);
        System.out.println("b1:"+b1);
        System.out.println("b:"+b);

        b1.setY(99);
        System.out.println("b1:"+b1);
        System.out.println("b"+b);

        Collection o=new ArrayList();
        o.add("qwq");
        o.add("OvO");
        o.add("QUQ");
        o.add("TAT");
        o.add("=A=");
        System.out.println(o);
        System.out.println("size:"+o.size());
        System.out.println("是否为空集"+c.isEmpty());
        o.clear();
        System.out.println("集合已清空");
        System.out.println("o");
        System.out.println("size:"+c.size());
        System.out.println("是否为空集"+c.isEmpty());

        String[]array={"one","two","three","four","five"};
        System.out.println("array:"+ Arrays.toString(array));
        List<String> lis=Arrays.asList(array);
        System.out.println("lis"+lis);

        array[1]="ten";
        System.out.println("array:"+Arrays.toString(array));
        System.out.println("lis:"+lis);
        lis.set(4,"nine");
        System.out.println("array:"+Arrays.toString(array));
        System.out.println("lis:"+lis);
        lis.add("one");


        Collection q=new ArrayList();
        q.add("hi");
        q.add("hello");
        q.add("hellow");
        System.out.println("q:"+q);

        Collection q2=new ArrayList();
        q2.add("what");
        q2.add("who");
        q2.add("why");
        System.out.println("q2:"+q2);

        q.addAll(q2);
        System.out.println("q:"+q);
        System.out.println("q2:"+q2);

        Collection q3=new ArrayList();
        q3.add("what");
        q3.add("are");
        q3.add("you");
        System.out.println("q3:"+q3);
        boolean contains2=q2.containsAll(q3);
        System.out.println("是否包含："+contains2);
        q.retainAll(q3);
        System.out.println("q:"+q);
        System.out.println("q3:"+q3);

        q.removeAll(q3);
        System.out.println("q:"+q);
        System.out.println("q3:"+q3);



        Collection<String>cc=new ArrayList<>();
        cc.add("qwq");
        cc.add("ovo");
        cc.add("=v=");
        cc.add("vov");
        cc.add("mom");
        System.out.println(cc);

        String[]array1=cc.toArray(new String[9]);
        System.out.println(Arrays.toString(array1));



        Collection<Point>qq=new ArrayList<>();
        qq.add(new Point(1,2));
        qq.add(new Point(2,3));
        qq.add(new Point(3,4));
        qq.add(new Point(4,5));

        Iterator<Point>it=qq.iterator();
        while(it.hasNext()){
            Point w=it.next();
            System.out.println(w);
        }

        for(Point w:qq){
            System.out.println(w);
        }



        Collection c3=new ArrayList();
        c3.add("qwq");
        c3.add("***");
        c3.add("=V=");
        c3.add("***");
        c3.add("wow");
        c3.add("***");
        c3.add("QVQ");
        System.out.println(c3);

        Iterator iter = c3.iterator();
        while (iter.hasNext()){
            String str=(String)iter.next();
            System.out.println(str);
            if ("***".equals(str)){
                //c3.remove(str);
                iter.remove();
            }
        }
        System.out.println(c3);



        String[] arr = {"one","two","three","four","five"};
        for(int i=0;i<arr.length;i++){
            System.out.println(arr[i]);
        }
        for(String str : arr){
            System.out.println(str);
        }

        Collection c1 = new ArrayList();
        c1.add("one");
        c1.add("two");
        c1.add("three");
        c1.add("four");
        c1.add("five");
        Iterator ite = c1.iterator();
        while(ite.hasNext()){
            String str = (String)ite.next();
            System.out.println(str);
        }
        for(Object obj : c1){
            String str = (String)obj;
            System.out.println(str);
        }

    }
}
